﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="telephone=no" name="format-detection" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <link href="../Styles/header.css" rel="stylesheet" />
    <link href="../Styles/foot.css" rel="stylesheet" />
    <link href="../Styles/reset.css" rel="stylesheet" />
    <link href="../Styles/User.css" rel="stylesheet" />
    <script src="../Javascript/jquery-1.6.2.min.js"></script>
</head>
<body>
    <div class="header" id="header">
        <span class="headline">用户中心</span>
    </div>
    <section>
        <div class="user">
            <div class="info">
                <ul class="clearfix">
                    <li>用户名：<a id="loginName" onclick="JavaScript:void(0)"></a></li>
                    <li>用户昵称：<a id="nickName" onclick="JavaScript:void(0)"></a></li>
                </ul>
            </div>
            <div class="management order">
                <h2>订单管理</h2>
                <ul class="pending">
                    <li>
                        <a class="last" href="MyOrder.html" title="" target="">订单列表&nbsp;</a>
                        <a class="link"><span class="more"><span class="inner"></span></span></a>
                    </li>
                </ul>
            </div>
            <div class="account order">
                <h2>账户管理</h2>
                <ul>
                    <li>
                        <a href="CustomerConsigneeList.html">收货地址</a>
                        <a class="link"><span class="more"><span class="inner"></span></span></a>
                    </li>
                    <li>
                        <a href="#">修改密码</a>
                        <a class="link"><span class="more"><span class="inner"></span></span></a>
                    </li>
                </ul>
            </div>
            <div class="quit" id="divLogin">
                <a href="Login.html" id="btn_Login" class="btn">登录</a>
            </div>
            <div class="quit" id="divQuit">
                <a id="btn_quit" class="btn" onclick="LogOut()">退出登录</a>
            </div>
            <div class="service">客服电话：<a class="tel" href="tel:0355-8888519">0355-8888519</a></div>
        </div>
    </section>

    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                url: "../Services/CustomerService.asmx/HasLogin",
                dataType: "json",
                success: function (data, flag) {
                    if (data.IsSucceed) {
                        if (data.Result.HasLogin) {
                            $("#divQuit").show();
                            $("#divLogin").hide();
                            //初始化相关数据
                            $("#loginName").html(data.Result.User.LoginName);
                            $("#nickName").html(data.Result.User.NickName);
                        }
                        else {
                            $("#divQuit").hide();
                            $("#divLogin").show();
                        }
                    }
                    else {
                        alert(data.ErrorMessage);
                    }
                },
                error: function (e, d, s) {
                }
            });
        });

        function LogOut() {
            $.ajax({
                type: "POST",
                url: "../Services/CustomerService.asmx/LogOut",
                dataType: "json",
                success: function (data, flag) {
                    if (data.IsSucceed) {
                        document.location.href = document.location.href;
                    }
                    else {
                        alert(data.ErrorMessage);
                    }
                },
                error: function (e, d, s) {
                }
            });
        }
    </script>
</body>
</html>
